import 'dart:convert';

import 'package:get/get.dart';
import 'package:meePet/bean/FoundTabListData.dart';
import 'package:meePet/net/RequestManager.dart';
import 'package:meePet/utils/LogUtils.dart';

import '../../base/LiveData.dart';

class FoundFragmentVM extends GetxController {
  LiveData<List<FoundTab>?> tabLd = LiveData();

  @override
  void onReady() {
    requestFoundTabData();
    super.onReady();
  }

  void requestFoundTabData() {
    RequestManager.getClient()
        .options("1")
        .then((value) => _dealWithTabData(value));
  }

  void _dealWithTabData(FoundTabListData data) {
    if (data.isSuccess()) {
      String netConfig = json.encode(data.data);
      LogUtils.i("网络获取的发现页面tab配置：$netConfig");
      tabLd.post(data.data?.list);
    } else {
      LogUtils.i("请求发现页面tab配置错误：${data.code}:${data.msg}");
    }
  }
}
